
clear all 

//define folder global here

gl Inputs "$folder\1_Inputs"
gl Intermediate "$folder\2_Intermediate"
gl Outputs "$folder\3_Outputs"

********************************************************************************

use "${Intermediate}\Combined for forloops.dta", clear

keep if inlist(outcome, "movo", "stat", "an13") & inlist(spec, "ldv", "ivac") & inlist(time, "q0104", "q0508")

********************************************************************************
* DEFINE LOCALS THROUGH FOR LOOPS HERE
********************************************************************************
levelsof outcome, local(outcomes)
levelsof group, local(groups)
levelsof spec, local(specs)
levelsof time, local(times)
levelsof geo, local(geos)
levelsof item, local(items)

foreach outx in `outcomes' {
	local id1 = "`outx'"
	
	foreach grox in `groups' {
		local id2 = "`grox'"
		
		foreach spex in `specs' {
			local id3 = "`spex'"
			
			foreach timx in `times' {
				local id4 = "`timx'"
				
				foreach geox in `geos' {
					local id5 = "`geox'"
					
					foreach itex in `items' {
						local id6 = "`itex'"
		
					levelsof value if 	outcome=="`outx'" & ///
										group=="`grox'" & ///
										spec=="`spex'" & ///
										time=="`timx'" & ///
										geo=="`geox'" & ///
										item=="`itex'" , ///
						clean local(`id1'_`id2'_`id3'_`id4'_`id5'_`id6')
						di "`id1'_`id2'_`id3'_`id4'_`id5'_`id6'"
						
					}
				}
			}
		}
	}
}

				
// to start off lines without errors
gl x " "


texdoc init "${Outputs}/Supplementary data_Table_I1.tex", replace force 
tex {\footnotesize \begin{tabular}{l c c c c c c c} \hline \toprule ///
	& \multicolumn{3}{c}{\textbf{1-4 Quarters After Filing}} ///
	& & \multicolumn{3}{c}{\textbf{5-8 Quarters After Filing}} \\
	
tex \cmidrule{2-4} \cmidrule{6-8}
	
tex	& $ {\scriptsize \mathbb{E}[Y \vert E=0]}$ & OLS & IV ///
	& & $ {\scriptsize \mathbb{E}[Y \vert E=0]}$ & OLS & IV \\

tex & (1) & (2) & (3) & & (4) & (5) & (6) \\
tex \cline{2-4} \cline{6-8}

tex 					 	& & & & & & & \\
tex $x \textbf{Not at eviction address or unobserved:} & `movo_a_ldv_q0104_c_m' 		& `movo_a_ldv_q0104_c_co' 			& `movo_a_ivac_q0104_c_co' ///
							& & `movo_a_ldv_q0508_c_m' 		& `movo_a_ldv_q0508_c_co' 			& `movo_a_ivac_q0508_c_co' \\
tex							& `movo_a_ldv_q0104_c_mse' 		& `movo_a_ldv_q0104_c_se' 			& `movo_a_ivac_q0104_c_se' ///
							& & `movo_a_ldv_q0508_c_mse' 	& `movo_a_ldv_q0508_c_se' 			& `movo_a_ivac_q0508_c_se' \\
tex 						& \multicolumn{3}{r}{[`movo_a_ldv_q0104_c_obs']} 					& & \multicolumn{3}{r}{[`movo_a_ldv_q0508_c_obs']} \\							
tex $x \multicolumn{8}{l}{\textit{Cook County, By Group}} \\								
tex $x ~~~Female 			& `movo_f_ldv_q0104_c_m' 		& `movo_f_ldv_q0104_c_co' 			& `movo_f_ivac_q0104_c_co' ///
							& & `movo_f_ldv_q0508_c_m' 		& `movo_f_ldv_q0508_c_co' 			& `movo_f_ivac_q0508_c_co' \\ 		
tex $x 						& `movo_f_ldv_q0104_c_mse' 		& `movo_f_ldv_q0104_c_se' 			& `movo_f_ivac_q0104_c_se' ///
							& & `movo_f_ldv_q0508_c_mse' 	& `movo_f_ldv_q0508_c_se' 			& `movo_f_ivac_q0508_c_se' \\ 		
tex $x ~~~Black  			& `movo_b_ldv_q0104_c_m' 		& `movo_b_ldv_q0104_c_co' 			& `movo_b_ivac_q0104_c_co' ///
							& & `movo_b_ldv_q0508_c_m' 		& `movo_b_ldv_q0508_c_co' 			& `movo_b_ivac_q0508_c_co' \\ 
tex $x 			  			& `movo_b_ldv_q0104_c_mse' 		& `movo_b_ldv_q0104_c_se' 			& `movo_b_ivac_q0104_c_se' ///
							& & `movo_b_ldv_q0508_c_mse' 		& `movo_b_ldv_q0508_c_se' 			& `movo_b_ivac_q0508_c_se' \\ 				
tex \midrule	
tex 						& & & & & & & \\
tex $x \textbf{Moved out of state:} & `stat_a_ldv_q0104_c_m' 		& `stat_a_ldv_q0104_c_co' 			& `stat_a_ivac_q0104_c_co' ///
							& & `stat_a_ldv_q0508_c_m' 		& `stat_a_ldv_q0508_c_co' 			& `stat_a_ivac_q0508_c_co' \\
tex							& `stat_a_ldv_q0104_c_mse' 		& `stat_a_ldv_q0104_c_se' 			& `stat_a_ivac_q0104_c_se' ///
							& & `stat_a_ldv_q0508_c_mse' 	& `stat_a_ldv_q0508_c_se' 			& `stat_a_ivac_q0508_c_se' \\
tex							& \multicolumn{3}{r}{[`stat_a_ldv_q0104_c_obs']} 					& & \multicolumn{3}{r}{[`stat_a_ldv_q0508_c_obs']} \\
tex $x \multicolumn{8}{l}{\textit{Cook County, By Group}} \\								
tex $x ~~~Female 			& `stat_f_ldv_q0104_c_m' 		& `stat_f_ldv_q0104_c_co' 			& `stat_f_ivac_q0104_c_co' ///
							& & `stat_f_ldv_q0508_c_m' 		& `stat_f_ldv_q0508_c_co' 			& `stat_f_ivac_q0508_c_co' \\ 		
tex $x 						& `stat_f_ldv_q0104_c_mse' 		& `stat_f_ldv_q0104_c_se' 			& `stat_f_ivac_q0104_c_se' ///
							& & `stat_f_ldv_q0508_c_mse' 	& `stat_f_ldv_q0508_c_se' 			& `stat_f_ivac_q0508_c_se' \\ 		
tex $x ~~~Black  			& `stat_b_ldv_q0104_c_m' 		& `stat_b_ldv_q0104_c_co' 			& `stat_b_ivac_q0104_c_co' ///
							& & `stat_b_ldv_q0508_c_m' 		& `stat_b_ldv_q0508_c_co' 			& `stat_b_ivac_q0508_c_co' \\ 
tex $x 			  			& `stat_b_ldv_q0104_c_mse' 		& `stat_b_ldv_q0104_c_se' 			& `stat_b_ivac_q0104_c_se' ///
							& & `stat_b_ldv_q0508_c_mse' 	& `stat_b_ldv_q0508_c_se' 			& `stat_b_ivac_q0508_c_se' \\ 	

tex \midrule
tex 						& & & & & & & \\
tex $x \textbf{Earnings out of 13 states:} & `an13_a_ldv_q0104_c_m' 		& `an13_a_ldv_q0104_c_co' 			& `an13_a_ivac_q0104_c_co' ///
							& & `an13_a_ldv_q0508_c_m' 		& `an13_a_ldv_q0508_c_co' 			& `an13_a_ivac_q0508_c_co' \\
tex							& `an13_a_ldv_q0104_c_mse' 		& `an13_a_ldv_q0104_c_se' 			& `an13_a_ivac_q0104_c_se' ///
							& & `an13_a_ldv_q0508_c_mse' 	& `an13_a_ldv_q0508_c_se' 			& `an13_a_ivac_q0508_c_se' \\
tex							& \multicolumn{3}{r}{[`an13_a_ldv_q0104_c_obs']} 					& & \multicolumn{3}{r}{[`an13_a_ldv_q0508_c_obs']} \\

tex $x \multicolumn{8}{l}{\textit{Cook County, By Group}} \\								
tex $x ~~~Female 			& `an13_f_ldv_q0104_c_m' 		& `an13_f_ldv_q0104_c_co' 			& `an13_f_ivac_q0104_c_co' ///
							& & `an13_f_ldv_q0508_c_m' 		& `an13_f_ldv_q0508_c_co' 			& `an13_f_ivac_q0508_c_co' \\ 		
tex $x 						& `an13_f_ldv_q0104_c_mse' 		& `an13_f_ldv_q0104_c_se' 			& `an13_f_ivac_q0104_c_se' ///
							& & `an13_f_ldv_q0508_c_mse' 	& `an13_f_ldv_q0508_c_se' 			& `an13_f_ivac_q0508_c_se' \\ 		
tex $x ~~~Black  			& `an13_b_ldv_q0104_c_m' 		& `an13_b_ldv_q0104_c_co' 			& `an13_b_ivac_q0104_c_co' ///
							& & `an13_b_ldv_q0508_c_m' 		& `an13_b_ldv_q0508_c_co' 			& `an13_b_ivac_q0508_c_co' \\ 
tex $x 			  			& `an13_b_ldv_q0104_c_mse' 		& `an13_b_ldv_q0104_c_se' 			& `an13_b_ivac_q0104_c_se' ///
							& & `an13_b_ldv_q0508_c_mse' 		& `an13_b_ldv_q0508_c_se' 			& `an13_b_ivac_q0508_c_se' \\ 	

tex \bottomrule \\
tex	\end{tabular} }
texdoc close
